﻿/// <reference path="ASPxScriptIntelliSense.js" />

/*!
* accounting.js javascript library v0.2.2 | https://josscrowcroft.github.com/accounting.js/
* Copyright 2011 | Joss Crowcroft | License: http://www.gnu.org/licenses/gpl-3.0.txt
*/
var accounting = function () {
    function q(a) { return !!(a === "" || a && a.charCodeAt && a.substr) } function n(a) { return u ? u(a) : v.call(a) === "[object Array]" } function r(a) { return v.call(a) === "[object Object]" } function s(a, b) { for (var c in b) b.hasOwnProperty(c) && a[c] == null && (a[c] = b[c]); return a } function j(a, b, c) { var g = [], d, h; if (!a) return g; if (w && a.map === w) return a.map(b, c); for (d = 0, h = a.length; d < h; d++) g[d] = b.call(c, a[d], d, a); return g } function o(a, b) { a = Math.round(Math.abs(a)); return isNaN(a) ? b : a } function x(a) {
        var b = i.currency.format;
        typeof a === "function" && (a = a()); if (q(a) && a.match("%v")) return { pos: a, neg: a.replace("-", "").replace("%v", "-%v"), zero: a }; else if (!a || !a.pos || !a.pos.match("%v")) return !q(b) ? b : i.currency.format = { pos: b, neg: b.replace("%v", "-%v"), zero: b }; return a
    } function k(a, b) { if (n(a)) return j(a, function (a) { return k(a, b) }); var b = b || ".", c = parseFloat(("" + (a || 0)).replace(RegExp("[^0-9-" + b + "]", ["g"]), "").replace(b, ".")); return !isNaN(c) ? c : 0 } function t(a, b) {
        var b = o(b, i.number.precision), c = Math.pow(10, b); return (Math.round(a * c) /
c).toFixed(b)
    } function p(a, b, c, g) { if (n(a)) return j(a, function (a) { return p(a, b, c, g) }); var a = k(a), d = s(r(b) ? b : { precision: b, thousand: c, decimal: g }, i.number), h = o(d.precision), e = a < 0 ? "-" : "", f = parseInt(t(Math.abs(a || 0), h), 10) + "", m = f.length > 3 ? f.length % 3 : 0; return e + (m ? f.substr(0, m) + d.thousand : "") + f.substr(m).replace(/(\d{3})(?=\d)/g, "$1" + d.thousand) + (h ? d.decimal + t(Math.abs(a), h).split(".")[1] : "") } function y(a, b, c, g, d, h) {
        if (n(a)) return j(a, function (a) { return y(a, b, c, g, d, h) }); var a = k(a), e = s(r(b) ? b : { symbol: b, precision: c,
            thousand: g, decimal: d, format: h
        }, i.currency), f = x(e.format); return (a > 0 ? f.pos : a < 0 ? f.neg : f.zero).replace("%s", e.symbol).replace("%v", p(Math.abs(a), o(e.precision), e.thousand, e.decimal))
    } function z(a, b, c, g, d, h) {
        if (!a) return []; var e = s(r(b) ? b : { symbol: b, precision: c, thousand: g, decimal: d, format: h }, i.currency), f = x(e.format), m = f.pos.indexOf("%s") < f.pos.indexOf("%v") ? true : false, l = 0, a = j(a, function (a) {
            if (n(a)) return z(a, e); else {
                a = k(a); a = (a > 0 ? f.pos : a < 0 ? f.neg : f.zero).replace("%s", e.symbol).replace("%v", p(Math.abs(a),
o(e.precision), e.thousand, e.decimal)); if (a.length > l) l = a.length; return a
            } 
        }); return j(a, function (a) { return q(a) && a.t < l ? m ? a.replace(e.symbol, e.symbol + Array(l - a.length + 1).join(" ")) : Array(l - a.length + 1).join(" ") + a : a })
    } var i = { currency: { symbol: "$", format: "%s%v", decimal: ".", thousand: ",", precision: 2, grouping: 3 }, number: { precision: 0, grouping: 3, thousand: ",", decimal: "."} }, w = Array.prototype.map, u = Array.isArray, v = Object.prototype.toString; return { settings: i, formatMoney: y, formatNumber: p, formatColumn: z, toFixed: t,
        unformat: k
    }
} ();




_wsIsESCAttached = false;
function _wsAttachESCOnInit(s, args) {
    if (!_wsIsESCAttached) {
        ASPxClientUtils.AttachEventToElement(document, "keydown", _wsDocumentKeyDown); // ESC
        _wsIsESCAttached = true;
    }
}

function setTooltip() {




//    $(".tooltip").remove();
//    $(".tt").data('tooltip').show = function () { $(".tooltip").remove(); }

    if ($(".tooltip").length) {
        $(".tooltip").remove();
    } 


    $(".tt").tooltip({ effect: 'slide', delay: 0 });
    

//    $(".tt").tooltip({

//        //the trick is to set it like this
//        events: { def: "click,mouseout" },

//      
//        //the effect
//        effect: 'slide'
//    });
}
function initialize() {

    $(document).ready(function () {
        $('.toggleButton').checkbox();
    });


    setHeartbeat();
    //$("[title]").tooltip();
    $(".tt").tooltip({ effect: 'slide', delay: 0 });

    _wsAttachESCOnInit();


    $(".tt").tooltip({ effect: 'slide', delay: 0 });
    
//    Shadowbox.init({
//        // let's skip the automatic setup because we don't have any
//        // properly configured link elements on the page
//        skipSetup: true
//    });

    $('.lightbox').lightbox();
    


}

function setHeartbeat() {
    setTimeout("heartbeat()", 5 * 1000);
}

function heartbeat() {
//    alert('test');
    //    setHeartbeat();
    var randomnumber = Math.floor(Math.random() * 101)
    $.get(
        "SessionHeartbeat.ashx?Id=" + randomnumber,
        null,
        function (data) {
            $("#heartbeat").show().fadeOut(1000); // just a little "red flash" in the corner :) 
            //alert(data);
            setHeartbeat();
        },
        "html"
    );
}


function _wsDocumentKeyDown(evt) {
    if (ASPxClientUtils.GetKeyCode(evt) == 27) {
        closePopups();
        return false;
    }
    return true;
}

var popupClick = false;
function box(url) {
    popupClick = true;
    $.lightbox(url);

//    Shadowbox.open({
//        content:url,
//        player:"img",
//        title: "Article Detail"
//        
//    });


    //Shadowbox.init({ initialHeight: 100, initialWidth: 100, modal: true, overlayOpacity: 0.8 });
    return false;

}


function showSummary() {
    popupClick = true;
  
    var content = $("#summary7c")[0].innerHTML;
    var htm = $(content);

    $.lightbox(htm, {
        width: 350,
        height:185
    });
     
    return false;
}




function closePopups() {
    if (typeof popBigPhoto != "undefined")
        popBigPhoto.Hide();
    if (typeof popRezerveLines != "undefined")
        popRezerveLines.Hide();
    if (typeof popHistory!= "undefined")
        popHistory.Hide();
}

function bigimg(productId, header) {
    var url = "../images/articles/l_" + productId + ".png";
    imgBigPopup.SetImageUrl(url);
    popBigPhoto.SetSize(450, 500);
    var saId = "sa" + productId;
    popBigPhoto.ShowAtElementByID(saId);
}
function closeBigimg() {
    if (typeof popBigPhoto != "undefined")
    {
        imgBigPopup.SetImageUrl('../images/bigLoading.jpg');
        popBigPhoto.Hide();
    }
}


 
 



